package com.googlecode.animator.controller
{
	
	import com.googlecode.animator.data.markers.GlobalMarkerVO;
	import com.googlecode.animator.data.Notifications;
	import com.googlecode.animator.data.objects3d.Object3DVO;
	import com.googlecode.animator.data.cameras.CameraVO;
	
	import org.papervision3d.objects.DisplayObject3D;
	import org.puremvc.as3.interfaces.INotification;
		
	/**
	 * Resets the project to its default state. 
	 * @author USER
	 * 
	 */
	public class ResetProjectCommand extends BaseCommand
	{
		/**
		 * Executes command. 
		 * @param notification
		 * 
		 */
		override public function execute(notification:INotification):void
		{
			super.execute(notification);
			
			// remove all global markers
			for each(var globalMarker:GlobalMarkerVO in settings.globalMarkers)
			{
				sendNotification(Notifications.TIMELINE_GLOBAL_MARKER_REMOVED, globalMarker.id);
				settings.removeGlobalMarker(globalMarker.id);
				
			}
			
			// remove all objects3D from model
			for each(var object3D:Object3DVO in settings.objects3D)
			{
				settings.deleteObject3D(object3D.name);				
			}
						
			
			// remove all cameras
			for each(var camera3D:CameraVO in settings.cameras)
			{
				delete settings.cameras[camera3D.name];
			}
			
			// remove all objects from scene
			for each(var object3DinScene:DisplayObject3D in settings.scene.children)
			{
				settings.scene.removeChild(object3DinScene);
				//sendNotification(Notifications.OBJECT3D_DELETED, object3DinScene.name);
			}
			
			// ensure there are no viewport VOs in model
			settings.clearAllViewports();
			
			// clear all viewports from GUI
			/* Application.application[ProjectConstants.VIEWPORT_1].removeAllChildren();
			Application.application[ProjectConstants.VIEWPORT_2].removeAllChildren();
			Application.application[ProjectConstants.VIEWPORT_3].removeAllChildren();
			Application.application[ProjectConstants.VIEWPORT_4].removeAllChildren() ;*/
			
			
			sendNotification(Notifications.PROJECT_IS_RESET);
			
		}
	}
}